package com.learn.project.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

/**
 * @author lijiajun
 * @date 2023/11/21
 */
@Slf4j
public class RoutingDataSource extends AbstractRoutingDataSource {

    @Override
    protected Object determineCurrentLookupKey() {
        String dbSource = DbContextHolder.get();
        log.info("current datasource：{}", dbSource);
        return dbSource;
    }
}
